Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rc14 #209

Merged
merged 1 commit into from
Jun 6, 2024
Merged

rc14 #209

merged 1 commit into from
Jun 6, 2024

Conversation

edisonz0718
Copy link
Contributor

@edisonz0718 edisonz0718 commented Jun 6, 2024

Summary by CodeRabbit

  • New Features

    • Added IPAccountClient and RoyaltyClient to the SDK.
    • Introduced new types: AttachLicenseTermsResponse, LicenseTermsId, ClaimRevenueRequest, ClaimRevenueResponse, and PermissionSignatureRequest.
    • Added getPermissionSignature function for permission management.
  • Improvements

    • Updated attachLicenseTerms and getLicenseTerms methods for enhanced license management.
    • Simplified createNFTCollection method in NftClient.
    • Replaced RoyaltyVaultAddress type with Address in royalty management.
  • Refactor

    • Replaced references to account with wallet of type WalletClient across various modules.
    • Refactored getPermissionSignature function for better code clarity and performance.
  • Bug Fixes

    • Ensured nftContract is not null before assignment in integration tests.
    • Improved error handling and logic in signing operations.
  • Tests

    • Updated test cases to align with changes in wallet and account handling.
    • Added new stubs and modified existing test cases for enhanced test coverage.

* Export signature method

* Modify calling signTypedData by wallet client

* Upload pnpm-lock.yaml

* Export some types

* Refactor nftClient in order to better generate react sdk

* Fix test about nftClient

* Fix integration test

* Rename SignatureHelpParameter to PermissionSignatureRequest
Copy link

coderabbitai bot commented Jun 6, 2024

Walkthrough

The updates to the core SDK involve version upgrades and substantial enhancements across several components. Key changes include new exports, type modifications, and method signature updates. The integration of WalletClient in place of account across various files, along with the introduction of new types and error handling improvements, aims to enhance functionality and robustness.

Changes

Files/Paths Change Summaries
packages/core-sdk/package.json Updated version from 1.0.0-rc.13 to 1.0.0-rc.14.
.../src/index.ts Added exports for IPAccountClient and RoyaltyClient; introduced new types and modified existing ones.
.../src/resources/ipAsset.ts Replaced account with wallet of type WalletClient in IPAssetClient class.
.../src/resources/license.ts Added new imports, updated method signatures, and modified return objects to include new fields.
.../src/resources/nftClient.ts Simplified method signatures by removing generic type parameters.
.../src/resources/permission.ts Replaced account with wallet of type WalletClient in PermissionClient class.
.../src/resources/royalty.ts Replaced RoyaltyVaultAddress type with Address in RoyaltyClient class.
.../src/types/common.ts Added imports for Address and WalletClient; introduced PermissionSignatureRequest type.
.../src/types/resources/license.ts Updated mintingFee field and introduced new types AttachLicenseTermsResponse and LicenseTermsId.
.../src/types/resources/nftClient.ts Simplified CreateNFTCollectionResponse type by removing conditional logic.
.../src/types/resources/royalty.ts Removed RoyaltyVaultAddress type alias.
.../src/utils/sign.ts Refactored the getPermissionSignature function.
.../test/integration/ipAccount.test.ts Added walletClient to imports and updated getPermissionSignature usage.
.../test/integration/ipAsset.test.ts Updated assignment of nftContract to handle potential null values.
.../test/unit/resources/ipAsset.test.ts Modified usage of walletMock for signing typed data.
.../test/unit/resources/nftClient.test.ts Updated functionality related to creating an NFT collection.
.../test/unit/resources/permission.test.ts Added new stub for signTypedData in walletMock and updated error messages in test cases.
.../test/unit/utils/sign.test.ts Updated references from LocalAccount to WalletClient and introduced new error handling.

Poem

In the realm of code, a bunny hops,
Updating versions, it never stops.
Wallets now in place of accounts,
New types and exports, the changes mount.
With robust tests and functions clear,
The core SDK shines, let's cheer! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (5)
packages/core-sdk/src/types/common.ts (1)

10-18: The expanded PermissionSignatureRequest type definition is comprehensive and aligns with the SDK's enhanced functionality. Consider adding comments to each field for better clarity and maintainability.

packages/core-sdk/src/resources/nftClient.ts (1)

Line range hint 35-65: The updated createNFTCollection method in NftClient uses direct type references and includes comprehensive validation logic. Consider enhancing the error messages to provide more specific debugging information.

packages/core-sdk/src/index.ts (1)

Line range hint 9-96: The new exports and type definitions in index.ts enhance the SDK's functionality and modularity. Consider adding documentation for these new exports to improve the developer experience.

packages/core-sdk/src/utils/sign.ts (1)

Line range hint 20-52: The error handling is robust, ensuring the wallet client's capabilities are checked. Consider adding more specific error messages for better user guidance.

- throw new Error("The wallet client does not support signTypedData, please try again.");
+ throw new Error("The wallet client does not support signTypedData. Ensure your wallet client is updated or supports this feature.");
- throw new Error("The wallet client does not have an account, please try again.");
+ throw new Error("The wallet client does not have an account. Please check your wallet client configuration.");
packages/core-sdk/test/unit/resources/ipAsset.test.ts (1)

Line range hint 75-98: Handle potential issues when wallet lacks signTypedData.

-      const walletMock = createMock<WalletClient>();
-      walletMock.account = createMock<Account>();
-      ipAssetClient = new IPAssetClient(rpcMock, walletMock, "sepolia");
+      // Ensure walletMock is properly initialized with signTypedData or handle the absence gracefully
+      const walletMock = createMock<WalletClient>({ signTypedData: sinon.stub().resolves("signature") });
+      walletMock.account = createMock<Account>();
+      ipAssetClient = new IPAssetClient(rpcMock, walletMock, "sepolia");

This test case simulates a scenario where the wallet object does not have the signTypedData method, which throws an error. It's good to simulate this scenario, but ensure that the walletMock is initialized in a way that reflects realistic usage patterns, possibly by providing a default stub for signTypedData.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ddfa155 and 23c44a0.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml
Files selected for processing (18)
  • packages/core-sdk/package.json (1 hunks)
  • packages/core-sdk/src/index.ts (4 hunks)
  • packages/core-sdk/src/resources/ipAsset.ts (6 hunks)
  • packages/core-sdk/src/resources/license.ts (4 hunks)
  • packages/core-sdk/src/resources/nftClient.ts (2 hunks)
  • packages/core-sdk/src/resources/permission.ts (3 hunks)
  • packages/core-sdk/src/resources/royalty.ts (3 hunks)
  • packages/core-sdk/src/types/common.ts (1 hunks)
  • packages/core-sdk/src/types/resources/license.ts (3 hunks)
  • packages/core-sdk/src/types/resources/nftClient.ts (1 hunks)
  • packages/core-sdk/src/types/resources/royalty.ts (1 hunks)
  • packages/core-sdk/src/utils/sign.ts (2 hunks)
  • packages/core-sdk/test/integration/ipAccount.test.ts (3 hunks)
  • packages/core-sdk/test/integration/ipAsset.test.ts (1 hunks)
  • packages/core-sdk/test/unit/resources/ipAsset.test.ts (3 hunks)
  • packages/core-sdk/test/unit/resources/nftClient.test.ts (1 hunks)
  • packages/core-sdk/test/unit/resources/permission.test.ts (3 hunks)
  • packages/core-sdk/test/unit/utils/sign.test.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • packages/core-sdk/package.json
  • packages/core-sdk/src/types/resources/nftClient.ts
  • packages/core-sdk/src/types/resources/royalty.ts
Additional context used
Biome
packages/core-sdk/test/unit/resources/permission.test.ts

[error] 15-30: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

Additional comments not posted (19)
packages/core-sdk/src/types/common.ts (1)

1-1: The import statement correctly includes Address and WalletClient from "viem", aligning with the updated type usage across the SDK.

packages/core-sdk/src/types/resources/license.ts (2)

52-52: The updated mintingFee field in RegisterCommercialRemixPILRequest to accept string | number | bigint enhances flexibility and aligns with the SDK's broader type support.


65-68: The new AttachLicenseTermsResponse type, including txHash and an optional success field, is well-defined and useful for tracking the outcomes of license term attachments.

packages/core-sdk/test/integration/ipAccount.test.ts (3)

3-10: LGTM! The new imports are necessary for the updated tests.


Line range hint 70-81: LGTM! The update to use walletClient aligns with the SDK changes.


Line range hint 70-81: The test case logic is consistent and correctly implements the new SDK functionality.

packages/core-sdk/src/utils/sign.ts (1)

1-19: LGTM! The updated imports and the detailed function documentation enhance clarity and maintainability.

packages/core-sdk/test/unit/utils/sign.test.ts (2)

3-7: LGTM! The new imports are correctly used for the updated tests.


11-40: The updates to the test cases are thorough and effectively simulate the new error handling scenarios in the getPermissionSignature function.

packages/core-sdk/test/unit/resources/nftClient.test.ts (1)

105-106: The updates to the test cases reflect the simplified method signatures in the NftClient class and are correctly implemented.

packages/core-sdk/test/integration/ipAsset.test.ts (1)

141-141: Ensure nftContract is not null before assignment.

Consider adding a comment explaining why this check is necessary, to improve code readability.

packages/core-sdk/src/resources/royalty.ts (1)

257-257: Improve error handling in getRoyaltyVaultAddress.

Consider providing more detailed error messages to help with debugging.

packages/core-sdk/src/resources/permission.ts (1)

132-132: Ensure this.wallet is always of type WalletClient.

Verify that this.wallet is always correctly instantiated as WalletClient to avoid runtime type errors.

packages/core-sdk/test/unit/resources/permission.test.ts (1)

20-22: Improve testing of signTypedData method.

Consider adding more comprehensive tests to ensure that the signTypedData method is correctly handled in all scenarios.

Also applies to: 191-206

packages/core-sdk/src/resources/license.ts (3)

25-26: LGTM! The addition of new types AttachLicenseTermsResponse and LicenseTermsId aligns with the PR's objective to update type definitions.


Line range hint 162-200: The updated method signature for attachLicenseTerms now correctly returns AttachLicenseTermsResponse. Good use of detailed error handling and conditional logic to ensure robustness.


296-296: The updated method signature for getLicenseTerms now correctly returns PiLicenseTemplateGetLicenseTermsResponse. This change ensures type consistency across the application.

packages/core-sdk/src/resources/ipAsset.ts (1)

1-1: LGTM! The updated imports include WalletClient, which is used to replace account with wallet throughout the class, aligning with the PR's objectives.

packages/core-sdk/test/unit/resources/ipAsset.test.ts (1)

21-22: Ensure the signTypedData method is properly mocked.

This change properly mocks the signTypedData method of walletMock to return a fixed hash. This is crucial for consistent test results.

@edisonz0718 edisonz0718 merged commit f8908bb into main Jun 6, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants